/*
 *  $Id: MercilessMurder.cs 902 2009-11-28 21:53:21Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Earth.Spells {
    public class MercilessMurder: SpellCard<ChainData> {
        public MercilessMurder(): base("001_e_s_merciless_murder") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Earth;
            Value = 100;
            Target = new ChainTarget(IsNotSelfDispell, CreatureTarget.Own, EnchantmentTarget.OnlyDispellable);
        }

        private static readonly Languages.CardPhrase<MercilessMurder> NotVictim = new Languages.CardPhrase<MercilessMurder>("not_victim");

        private static bool IsNotSelfDispell(TargetArgs<ChainData> args) {
            TargetArgs<Creature> ca;
            TargetArgs<Affect> ea;
            if (!args.Target.GetArgs(out ca, out ea)) return false;
            if (ea.Target.Owner != ca.Target) return true;
            args.Player.Game.ErrorNotice(NotVictim.Phrase.GetText());
            return false;
        }

        protected override void DoAction(TargetArgs<ChainData> args) {
            TargetArgs<Creature> ca;
            TargetArgs<Affect> ea;
            if (!args.Target.GetArgs(out ca, out ea)) return;
            ca.Target.InstantDeath();
            ea.Target.Dispell();
        }
    }
}
